package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.service.IByMyStandardService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ByOrdersItem;
import com.ruoyi.system.service.IByOrdersItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ordersItemController
 * 
 * @author ruoyi
 * @date 2024-02-01
 */
@RestController
@RequestMapping("/system/item")
public class ByOrdersItemController extends BaseController
{
    @Autowired
    private IByOrdersItemService byOrdersItemService;
    /**
     * 查询ordersItem列表
     */
    @PreAuthorize("@ss.hasPermi('system:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(ByOrdersItem byOrdersItem)
    {
        startPage();
        List<ByOrdersItem> list = byOrdersItemService.selectByOrdersItemList(byOrdersItem);
        return getDataTable(list);
    }

    /**
     * 导出ordersItem列表
     */
    @PreAuthorize("@ss.hasPermi('system:item:export')")
    @Log(title = "ordersItem", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ByOrdersItem byOrdersItem)
    {
        List<ByOrdersItem> list = byOrdersItemService.selectByOrdersItemList(byOrdersItem);
        ExcelUtil<ByOrdersItem> util = new ExcelUtil<ByOrdersItem>(ByOrdersItem.class);
        util.exportExcel(response, list, "ordersItem数据");
    }

    /**
     * 获取ordersItem详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:item:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(byOrdersItemService.selectByOrdersItemById(id));
    }

    /**
     * 获取ordersItem详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:item:query')")
    @GetMapping(value = "/getByOrderId/{id}")
    public AjaxResult getByOrderId(@PathVariable("id") String id)
    {
        return success(byOrdersItemService.getByOrderId(id));
    }

    /**
     * 新增ordersItem
     */
    @PreAuthorize("@ss.hasPermi('system:item:add')")
    @Log(title = "ordersItem", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ByOrdersItem byOrdersItem)
    {
        return toAjax(byOrdersItemService.insertByOrdersItem(byOrdersItem));
    }

    /**
     * 修改ordersItem
     */
    @PreAuthorize("@ss.hasPermi('system:item:edit')")
    @Log(title = "ordersItem", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ByOrdersItem byOrdersItem)
    {
        return toAjax(byOrdersItemService.updateByOrdersItem(byOrdersItem));
    }

    /**
     * 删除ordersItem
     */
    @PreAuthorize("@ss.hasPermi('system:item:remove')")
    @Log(title = "ordersItem", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(byOrdersItemService.deleteByOrdersItemByIds(ids));
    }
}
